from fastmcp import FastMCP

# ----------------------------------------------------
# 1. Server Initialization with English Description
# ----------------------------------------------------

mcp = FastMCP(
    name="MathUtilityServer",  # Server's English name
    instructions="This server provides fundamental mathematical tools for performing arithmetic operations and verifying execution.",
    # Server's English instructions
)


# ----------------------------------------------------
# 2. Tool Definition with English Docstring
# ----------------------------------------------------

@mcp.tool()
def accumulate_and_verify(
        a: int,
        b: int
) -> int:
    """
    Computes the sum of two integers (a + b) and adds 3 to the result 
    to confirm the tool's successful execution.

    This function is primarily used for demonstration, where the addition of 3
    serves as a clear marker that the tool has been successfully invoked and executed.

    :param a: The first integer to be accumulated.
    :param b: The second integer to be accumulated.
    :return: The final accumulated result (a + b + 3).
    """

    # 核心计算：累加求和
    total_sum = a + b

    # 验证步骤：累加后在加3，以印证被成功调用
    result = total_sum + 3

    return result





# ----------------------------------------------------
# 3. Server Execution
# ----------------------------------------------------

if __name__ == "__main__":
    # 使用 stdio transport 运行，方便在命令行或与本地 AI Agent 集成
    print("FastMCP MathUtilityServer is running. Press Ctrl+C to stop.")
    mcp.run(transport="http", host="localhost", port=8080)